package com.skiving.cloud.admin.service.impl;

import cn.dev33.satoken.stp.StpInterface;
import com.skiving.cloud.admin.service.SysUserService;
import org.noear.solon.annotation.Component;
import org.noear.solon.annotation.Inject;

import java.util.List;

/**
 * 获取用户接口权限的实现类
 */
@Component
public class StpInterfaceImpl implements StpInterface {
    @Inject
    private SysUserService sysUserService;
    /**
     * 返回指定账号id所拥有的权限码集合
     *
     * @param loginId   账号id
     * @param loginType 账号类型
     * @return 该账号id具有的权限码集合
     */
    @Override
    public List<String> getPermissionList(Object loginId, String loginType) {
        return sysUserService.getUserPermissions((String) loginId);
    }

    /**
     * 返回指定账号id所拥有的角色标识集合
     *
     * @param loginId   账号id
     * @param loginType 账号类型
     * @return 该账号id具有的角色标识集合
     */
    @Override
    public List<String> getRoleList(Object loginId, String loginType) {
        return sysUserService.getUserRoles((String) loginId);
    }
}
